<?php

abstract class View {
    
    private $titulo;
    private $scriptExterno = array();
    private $cssExterno = array();
    
    public function getTitulo() {
        return $this->titulo;
    }

    public function setTitulo($titulo) {
        $this->titulo = $titulo;
    }
    
    public function imprimeHtml() {
        echo '<html>'.PHP_EOL;
        $this->imprimeHead();
        $this->imprimeBody();
        echo '</html>'.PHP_EOL;
    }
    
    protected function imprimeHead() {
        echo '<head>';
        echo '<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"/>'.PHP_EOL;
        echo '<title>' . $this->getTitulo() . '</title>'.PHP_EOL;
        $this->imprimeCss();
        $this->imprimeScript();
        echo '</head>'.PHP_EOL;    
    }
    
    public function addCssExterno($cssExterno) {
        $this->cssExterno[] = $cssExterno;
    }
    
    protected function imprimeCss() {
        foreach ($this->cssExterno as $sCss) {
            echo '<link rel="stylesheet" type="text/css" href="'.$sCss.'"/>'.PHP_EOL;
        }    
    }
    
    public function addScriptExterno($scriptExterno) {
        $this->scriptExterno[] = $scriptExterno;
    }    
    
    protected function imprimeScript() {
        foreach ($this->scriptExterno as $sScript) {
            echo '<script type="text/javascript" src="'.$sScript.'"></script>'.PHP_EOL;
        }
    }
    
    abstract protected function imprimeBody(); 
    
}